Mastering Windows PowerShell Scripting, Third Edition by Chris Dent

Mastering Windows PowerShell Scripting, Third Edition by Chris Dent

Author:Chris Dent [Chris Dent]
Language: eng
Format: epub, mobi
Tags: COM000000 - COMPUTERS / General, COM082000 - COMPUTERS / Bioinformatics, COM006000 - COMPUTERS / Buyer
Publisher: Packt publishing
Published: 2019-02-28T17:07:12+00:00


Arrays of null values are messy

This method of supplying arguments to execute a method is difficult to work with for all but the simplest of methods. An alternative is to use the .NET method InvokeMethod on the class object:

$class = Get-WmiObject Win32_Share -List

$inParams = $class.GetMethodParameters('Create')

$inParams.Name = 'Share1'

$inParams.Path = 'C:\Temp\Share1'

$inParams.Type = 0

$return = $class.InvokeMethod('Create', $inParams, $null)

The last argument, set to null here, is InvokeMethodOptions, which is most often used to define a timeout for the operation. Doing so is beyond the scope of this chapter.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.